import queue
class MaxQueue:

    def __init__(self):
            # 用一个双端队列维护最大值
            self.deque=queue.deque()
            self.queue=queue.Queue()

    def max_value(self) -> int:
        return self.deque[0] if self.deque else -1


    def push_back(self, value: int) -> None:
        # 最大值始终在第0位
        while self.deque and self.deque[-1]<value:
            self.deque.pop()
        self.deque.append(value)
        self.queue.put(value)


    def pop_front(self) -> int:
        if not self.deque:return -1
        ans=self.queue.get()
        if ans==self.deque[0]:
            self.deque.popleft()
        return ans



# Your MaxQueue object will be instantiated and called as such:
# obj = MaxQueue()
# param_1 = obj.max_value()
# obj.push_back(value)
# param_3 = obj.pop_front()